package com.dark;

import java.text.Collator;
import java.util.*;

/**
 * Created by tengxue on 15-10-21.
 * 一个简单的中文拼音排序。以前没有发现这个方法。java自带对于中文拼音的排序支持
 */
public class SampleChineseSort {

    private final static Comparator CHINA_COMPARE= Collator.getInstance(Locale.CHINA);

    private static void sortList(){
        List<String> list= Arrays.asList("张三","李四","王五");
        Collections.sort(list,CHINA_COMPARE);
        for(String entity:list){
            System.out.println(entity);
        }
    }

    private static void sortArray(){
        String[] att={"张三","李四","王五"};
        Arrays.sort(att,CHINA_COMPARE);
        for(String entity:att){
            System.out.println(entity);
        }
    }

    public static void main(String[] args){
        sortList();
        sortArray();
    }
}
